#ifndef MAC_LABEL_H
#define MAC_LABEL_H

#define FILE_DEVICE_SECMODCTL  0x00654322
#define DRVSECMODCTL_IOCTL_INDEX 123

#define XSECMODCTL_READ_AUDIT CTL_CODE(FILE_DEVICE_SECMODCTL, DRVSECMODCTL_IOCTL_INDEX + 27, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define XSECMODCTL_LOAD_WL_POLICY CTL_CODE(FILE_DEVICE_SECMODCTL, DRVSECMODCTL_IOCTL_INDEX + 28, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define XSECMODCTL_LOAD_MAC_OBJECT_LIST CTL_CODE(FILE_DEVICE_SECMODCTL, DRVSECMODCTL_IOCTL_INDEX + 29, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define XSECMODCTL_LOAD_MAC_SUBJECT_LIST CTL_CODE(FILE_DEVICE_SECMODCTL, DRVSECMODCTL_IOCTL_INDEX + 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define XSECMODCTL_SET_CONFIG CTL_CODE(FILE_DEVICE_SECMODCTL, DRVSECMODCTL_IOCTL_INDEX + 31, METHOD_BUFFERED, FILE_ANY_ACCESS)

enum dtype_mac_label
{
	TYPE(MAC_LABEL)=0x4220,
};

enum subtype_mac_label
{
	SUBTYPE(MAC_LABEL,LABEL)=0x01,
	SUBTYPE(MAC_LABEL,CTL_HEAD),
	SUBTYPE(MAC_LABEL,SUBJECT),
	SUBTYPE(MAC_LABEL,OBJECT),
	SUBTYPE(MAC_LABEL,AUDIT_HEAD),
	SUBTYPE(MAC_LABEL,FILE_EVENT)
};

typedef struct mac_label_ctl_head
{
    unsigned int uCode;         // -- 消息码
    unsigned int wParam;        // -- 扩展参数
    unsigned int lParam;        // -- 扩展参数
    unsigned int cntLen;        // -- 消息内容长度，不包括头部
}__attribute__((packed)) RECORD(MAC_LABEL,CTL_HEAD);

typedef struct mac_label_label
{
	unsigned short category;
	unsigned char sec_label;
    unsigned char inte_label;
}__attribute__((packed)) RECORD(MAC_LABEL,LABEL); 

typedef struct mac_label_subject
{
	char name[64];
    int user_id;
    RECORD(MAC_LABEL,LABEL) label;
}__attribute__((packed)) RECORD(MAC_LABEL,SUBJECT);

typedef struct mac_label_object
{
	unsigned char object_uuid[32];
    RECORD(MAC_LABEL,LABEL) label;
}__attribute__((packed)) RECORD(MAC_LABEL,OBJECT);


typedef struct mac_label_audit_head
{
	unsigned magic;
    int type;
    unsigned short length;
}__attribute__((packed)) RECORD(MAC_LABEL,AUDIT_HEAD);

typedef struct mac_label_file_event
{
    unsigned char optype;
	int uid;
    int nameLen;
    char * fileName;
}__attribute__((packed)) RECORD(MAC_LABEL,FILE_EVENT);
#endif
